﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using VAdvantage.Model;
using VAdvantage.ProcessEngine;


namespace VAdvantage.Process
{
    /// <summary>
    /// Create Periods of year
    /// </summary>
    public class YearCreatePeriods : SvrProcess
    {
        private int _cYearId = 0;

        /// <summary>
        /// Prepare
        /// </summary>
        protected override void Prepare()
        {
            _cYearId = GetRecord_ID();
        }

        /// <summary>
        /// Process
        /// </summary>
        /// <returns>info</returns>
        protected override String DoIt()
        {
            MYear year = new MYear(GetCtx(), _cYearId, Get_TrxName());
            if (_cYearId == 0 || year.Get_ID() != _cYearId)
                throw new Exception("@NotFound@: @C_Year_ID@ - " + _cYearId);
            log.Info(year.ToString());
            //
            if (year.CreateStdPeriods(null))
            {
                return "@OK@";
            }
            return "@Error@";
        }
    }
}
